<%@include file="/WEB-INF/pages/commons/commons.jsp"%>


<jsecurity:lacksPermission name="profile:viewProfile:*">
    No "profile:viewProfile:*" permission    
</jsecurity:lacksPermission>

<jsecurity:hasPermission name="profile:viewProfile:*">
<script type="text/javascript">
    $(document).ready(function(){

        $("#changePasswordLink").click(function() {
            $("#changePasswordSpace").html("<fmt:message key='global.loading'/>");
            $.get(
                    '<stripes:url beanclass="foo.bar.blog.web.action.registered.ProfileActionBean" event="viewChangePassword"/>',
                    function(data) {
                        $("#changePasswordSpace").hide();
                        $("#changePasswordSpace").html(data);
                        $("#changePasswordSpace").fadeIn();
                    }
              );
            $("#changePasswordSpace").fadeIn();
            return false;
        });

        $("#save").click(function() {
            $("#space").html("<fmt:message key='global.loading'/>");
            var form = this.form;
            var param = $(form).serializeArray();
            $.post(
                '<stripes:url beanclass="foo.bar.blog.web.action.registered.ProfileActionBean" event="save"/>',
                param,
                function(data) {
                    $("#space").hide();
                    $("#space").html(data);
                    $("#space").fadeIn();
                }
            );
            return false;
        });
    });
</script>

    <h2>Profile</h2>
    <stripes:messages />
    <stripes:errors globalErrorsOnly="true"/>


    <stripes:form method="POST" beanclass="foo.bar.blog.web.action.registered.ProfileActionBean">
        <stripes:errors globalErrorsOnly="false" />
        <table width="100%">
            <tr>
                <td><stripes:label for="user.disabled"/></td>
                <td><stripes:checkbox name="user.disabled" disabled="true"/></td>
            </tr>
            <tr>
                <td><stripes:label for="user.locked"/></td>
                <td><stripes:checkbox name="user.locked" disabled="true"/></td>
            </tr>
            <tr>
                <td><stripes:label for="user.expiryDate"/></td>
                <td><stripes:text name="user.expiryDate" disabled="true" /></td>         
            </tr>
            <tr>
                <td><stripes:label for="user.email"/>*</td>
                <td><stripes:text name="user.email"/></td>
            </tr>
            <tr>
                <jsecurity:hasPermission name="profile:changePassword:*">
                <td><label>Change Password</label></td>
                <td><a id="changePasswordLink" href=""><fmt:message key="profile.jsp.changePassword"/></a></td>
                </jsecurity:hasPermission>
                <jsecurity:lacksPermission name="profile:changePassword:*">
                    <td colspan="2">No "profile:changePassword:*" permission</td>
                </jsecurity:lacksPermission>
            </tr>
            <tr>
                <td colspan="2">
                     <jsecurity:hasPermission name="profile:editProfile">
                        <stripes:submit id="save" name="save"><fmt:message key="profile.jsp.submit"/></stripes:submit>
                     </jsecurity:hasPermission>
                     <jsecurity:lacksPermission name="profile:editProfile:*">
                        No "profile:editProfile:*" permission
                     </jsecurity:lacksPermission>    
                </td>
            </tr>
        </table>
    </stripes:form>
</jsecurity:hasPermission>

